]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
js/environment: Always use Shell.util_spawn_async functions if possible
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 3 May 2024 16:13:37 +0000 (18:13 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 24 May 2024 22:48:53 +0000 (22:48 +0000)
If no child setup is provided then all the shell extensions that use
GLib.spawn_async should actually use the shell spawning utils since we
are supposed to always restore the default nofile rlimit on launched
children.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3293>

js/ui/environment.js

index 4ce70367e90ae2d3617565293f95e5788efbed40..24e52d73917414655687a2a65c0a443e189d66a1 100644 (file)
@@ -348,14 +348,17 @@ if (slowdownEnv) {
 function wrapSpawnFunction(func) {
     const originalFunc = GLib[func];
     return function (workingDirectory, argv, envp, flags, childSetup, ...args) {
+        const commonArgs = [workingDirectory, argv, envp, flags];
         if (childSetup) {
             logError(new Error(`Using child GLib.${func} with a GLib.SpawnChildSetupFunc ` +
                 'is unsafe and may dead-lock, thus it should never be used from JavaScript. ' +
                 `Shell.${func} can be used to perform default actions or an ` +
                 'async-signal-safe alternative should be used instead'));
+            return originalFunc(...commonArgs, childSetup, ...args);
         }
 
-        return originalFunc(workingDirectory, argv, envp, flags, childSetup, ...args);
+        const retValue = Shell[`util_${func}`](...commonArgs, ...args);
+        return [true, ...Array.isArray(retValue) ? retValue : [retValue]];
     };
 }
 GLib.spawn_async = wrapSpawnFunction('spawn_async');